package xmls

var SystemInfoMapper = []byte(`
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "https://raw.githubusercontent.com/zhuxiujia/GoMybatis/master/mybatis-3-mapper.dtd">
<mapper>
    <!--logic_enable 逻辑删除字段-->
    <!--logic_deleted 逻辑删除已删除字段-->
    <!--logic_undelete 逻辑删除 未删除字段-->
    <!--version_enable 乐观锁版本字段,支持int,int8,int16,int32,int64-->
    <resultMap id="BaseResultMap" tables="t_system_info">
		<id column="id"  langType="int" />
		<result column="system_id" langType="int"   />
		<result column="info_name" langType="string"   />
		<result column="address" langType="string"   />
		<result column="database_url" langType="string"   />
		<result column="type" langType="string"   />
		<result column="username" langType="string"   />
		<result column="password" langType="string"   />
		<result column="database_name" langType="string"   />
		<result column="charset" langType="string"   />
		<result column="autocommit" langType="int"   />
		<result column="is_delete" langType="int"  logic_enable="true" logic_undelete="0" logic_deleted="1" />
    </resultMap>
	<deleteTemplate wheres="id?id = #{id}"/>
	<select id="GetAllSystemCount">
		select count(1) from t_system_info where 1=1
		<if test="info_name != ''">
			and info_name like #{'%'+info_name+'%'}
		</if>
		<if test="address != ''">
			and address like #{'%'+address+'%'}
		</if>
		and system_id = #{system_id} and is_delete = 0
	</select>
	<select id="GetSystemInfosByPage">
		select * from t_system_info where 1=1
		<if test="info_name != ''">
			and info_name like #{'%'+info_name+'%'}
		</if>
		<if test="address != ''">
			and address like #{'%'+address+'%'}
		</if>
		and system_id = #{system_id} and is_delete = 0 limit #{current},#{pageSize}
	</select>
	<select id="GetSystemInfoById">
		select * from t_system_info where id = #{id} and is_delete = 0
	</select>
	<insert id='AddSystemInfo'>
		INSERT INTO t_system_info (system_id, info_name, address, database_url, type, username, password, database_name, charset, autocommit, create_by, create_time, update_by, update_time, is_delete) 
		VALUES 
		(#{system_id}, #{info_name}, #{address}, #{database_url}, #{type}, #{username}, #{password},#{database_name}, #{charset}, #{autocommit}, 'root', current_timestamp, 'root', current_timestamp, 0)
	</insert>
	<update id='ModifySystemInfoById'>
		UPDATE t_system_info t
		SET t.system_id     = #{system_id},
			t.info_name     = #{info_name},
			t.address       = #{address},
			t.database_url  = #{database_url},
			t.type          = #{type},
			t.username      = #{username},
			t.password      = #{password},
			t.database_name = #{database_name},
			t.charset       = #{charset},
			t.autocommit    = #{autocommit},
			t.update_time   = current_timestamp
		WHERE t.id =  #{id}	
	</update>
	<select id="GetSystemsBySystemId">
		select * from t_system_info where system_id = #{id} and is_delete = 0
	</select>
</mapper>
`)
